home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 138
/
Volume 138 Aug 19 2011 - Damaged.iso
/
Games
/
hopes_babysitting_maze.swf
/
scripts
/
__Packages
/
HopeBSM_engine.as
Wrap
Text File
|
2011-08-19
|
10KB
|
346 lines
class HopeBSM_engine
{
var TARGETSCORE = 11000;
var endGameTimer_max = 16;
var GAMEQUAL = "MEDIUM";
var LOWQUAL_PROC = 5000;
function HopeBSM_engine()
{
}
function init(t_root, t_placeholder)
{
this.gameRoot = t_root;
this.gamePlaceholder = t_placeholder;
this.loadTime = getTimer();
trace("-- Init Hope Babysitting Maze Engine --");
this.hasPlayed = false;
this.soundMC = this.gamePlaceholder.createEmptyMovieClip("soundEngine_mc",3300);
this.soundEngine = new smashing.SoundEngine(this.soundMC,1,false);
this.soundEngine.createSound("music","Housemelody 22-03.wav");
this.soundEngine.createSound("puppy","Dog 2 Barks.wav");
this.soundEngine.createSound("pickup","squeak07.wav");
this.soundEngine.createSound("pickupSP","squeak07.wav");
this.soundEngine.createSound("pickupFinal","nicechime.wav");
this.interval = new smashing.IntervalEngine(this,"stepFrame");
this.interval.startFast();
this.pause();
this.loadLevelData();
this.goTitle();
}
function olr(event)
{
_global.RYMengine.onCheckLoginResponse(event);
}
function onCheckLoginResponse(event)
{
if(event.loggedIn == false)
{
this.loggedInUser = "";
}
else
{
this.loggedInUser = event.loggedIn;
}
}
function oli(event)
{
_global.RYMengine.onLogIn(event);
}
function onLogIn(event)
{
this.loggedInUser = event.username;
}
function olo(event)
{
_global.RYMengine.onLogOut(event);
}
function onLogOut(event)
{
this.loggedInUser = "";
}
function playMusic()
{
this.soundEngine.playSound("music",10000);
}
function stopMusic()
{
this.soundEngine.stopSound("music");
}
function playSound(t_name, t_loops)
{
this.soundEngine.playSound(t_name);
}
function stopSound(t_name)
{
if(t_name == undefined)
{
t_name = "music";
}
this.soundEngine.stopSound(t_name);
}
function changeVolume(t_vol)
{
this.soundEngine.changeVolume(t_vol);
}
function addScore(t_val)
{
this.n_score += t_val;
this.updateScore();
}
function loseScore()
{
this.n_score -= 50;
if(this.n_score < 0)
{
this.n_score = 0;
}
this.updateScore();
}
function updateScore()
{
this.gameRoot.txt_score.txt_score.text = this.n_score;
}
function startScript(t_script)
{
trace("- Start Script : " + t_script);
this.currentScript = t_script;
if(t_script === "meetBaby")
{
this.finishScript("meetBaby");
}
}
function finishScript(t_script)
{
trace("- Finish Script : " + t_script);
if(t_script === "meetBaby")
{
this.beatLevel();
}
}
function stepFrame(t_elapsed)
{
if(!this.paused)
{
this.a_levels[this.n_currentLevel].step(t_elapsed);
}
}
function startGame()
{
this.reset();
this.goGameplay();
this.startLevel();
this.hasPlayed = true;
}
function stopGame()
{
trace("- Stop and Clear game -");
this.stopSound();
this.pause();
this.clearLevel();
}
function reset()
{
this.n_currentLevel = 0;
this.currentScript = "finish";
this.n_score = 0;
this.pause();
}
function pause()
{
_quality = "HIGH";
this.stopMusic();
trace("Pause");
this.stopSound("dance");
this.paused = true;
}
function unpause()
{
_quality = this.GAMEQUAL;
trace("UnPause");
this.paused = false;
}
function goHopePage()
{
getUrl("/hope", "");
}
function goEverMe()
{
getUrl("/everme", "");
}
function quitForHighscore()
{
this.stopGame();
this.goHighscore();
}
function goHighscore()
{
this.gameRoot.gotoAndStop("highscore");
this.submitScore();
}
function submitScore()
{
this.gameRoot.txt_debug.text = this.activityid + " , " + this.n_score;
trace(this.loadTime);
var _loc2_ = getTimer() - this.loadTime;
this.module.dispatchEvent({type:"onAddModule",name:"submitScore_mc",content:"/modules/submitScore.swf",z:"top",gameid:this.activityid,score:this.n_score,time:_loc2_,silent:false,reload:true});
this.module.onScoreSubmitted = this.oss;
this.module.dispatchEvent({type:"onRegisterModuleListener",moduleName:"submitScore_mc",eventName:"onScoreSubmitted"});
}
function oss(event)
{
_global.hopeBSMrootPath.hopeBSMEngine.onScoreSubmitted(event);
}
function onScoreSubmitted(event)
{
if(this.n_score >= this.TARGETSCORE && this.loggedInUser != "")
{
this.goEverAward();
}
else
{
this.goTitle();
}
}
function startOver()
{
this.stopGame();
this.startGame();
this.gameRoot.house_mc.crib_mc.baby_mc.gotoAndStop("happy");
this.gameRoot.house_mc.crib_mc.baby_mc.anim.gotoAndPlay(1);
}
function goTitle()
{
this.pause();
this.gameRoot.gotoAndStop("title");
}
function goQuit()
{
this.pause();
this.gameRoot.gotoAndStop("quit");
this.gameRoot.window_mc.n_score = this.n_score;
}
function goEverAward()
{
this.gameRoot.gotoAndStop("everAward");
}
function goHelp()
{
this.pause();
this.gameRoot.gotoAndStop("help");
}
function leaveMenu()
{
this.goGameplay();
this.unpause();
}
function beatLevel()
{
this.pause();
this.n_score += 200 * this.n_currentLevel + 200;
this.n_score += Math.floor(this.a_levels[this.n_currentLevel].n_timer) * 50;
this.updateScore();
this.clearLevel();
if(this.n_currentLevel == 2)
{
this.beatGame();
}
else
{
this.gameRoot.gotoAndStop("levelend");
}
}
function getTimeSpent()
{
var _loc2_ = this.a_levels[this.n_currentLevel].n_timerMax - this.a_levels[this.n_currentLevel].n_timer;
this.a_levels[this.n_currentLevel].previousCompleteTime = _loc2_;
var _loc3_ = String(Math.ceil(_loc2_));
return _loc3_;
}
function getTotalTimeSpent()
{
var _loc3_ = 0;
var _loc2_ = this.a_levels.length;
while(true)
{
_loc2_;
if(!_loc2_--)
{
break;
}
_loc3_ += this.a_levels[_loc2_].previousCompleteTime;
}
var _loc4_ = String(Math.ceil(_loc3_));
return _loc4_;
}
function beatGame()
{
this.pause();
this.gameRoot.gotoAndStop("levelend2");
}
function gameOver()
{
this.pause();
this.gameRoot.gotoAndStop("gameover");
this.gameRoot.house_mc.crib_mc.baby_mc.gotoAndStop("cry2");
this.gameRoot.window_mc.n_score = this.n_score;
}
function goGameplay()
{
this.playMusic();
this.gameRoot.gotoAndStop("game");
this.gameRoot.txt_lvl.gotoAndStop(this.n_currentLevel + 1);
this.gameRoot.icons_lvl.gotoAndStop(this.n_currentLevel + 1);
this.updateScore();
this.unpause();
}
function goGameWin()
{
this.gameRoot.gotoAndStop("wingame");
this.gameRoot.window_mc.n_score = this.n_score;
}
function startLevel()
{
trace("-- Start Level " + (this.n_currentLevel + 1) + " -- ");
this.activeGame = this.gamePlaceholder.createEmptyMovieClip("game",1);
this.a_levels[this.n_currentLevel].start(this.activeGame);
this.unpause();
}
function restartLevel()
{
eval(this.gameRoot + ".enter_" + this.a_levels[this.n_currentLevel].store).gotoAndStop("hidden");
this.startLevel();
this.gameRoot.gotoAndPlay("loseOutro");
this.goGameplay();
}
function nextLevel()
{
this.n_currentLevel = this.n_currentLevel + 1;
this.startLevel();
this.goGameplay();
}
function clearLevel()
{
this.a_levels[this.n_currentLevel].clear();
this.activeGame.removeMovieClip();
}
function loadLevelData()
{
this.a_levels = [new Classes.bsmLevel(this),new Classes.bsmLevel(this),new Classes.bsmLevel(this)];
var _loc2_ = this.a_levels[0];
_loc2_.playerData = {assetID:"player_mc",x:111,y:235};
_loc2_.iconData = [{x:344,y:64,special:3},{x:236,y:110,special:0},{x:307,y:236,special:1},{x:236,y:236,special:4},{x:236,y:170,special:2},{x:117,y:166,special:6},{x:117,y:37,special:5}];
_loc2_.iconFrameNum = 1;
_loc2_.enemyData = [{assetID:"puppy_mc",startPoint:"point23",type:"puppy",speed:40}];
_loc2_ = this.a_levels[1];
_loc2_.playerData = {assetID:"player_mc",x:111,y:235};
_loc2_.iconData = [{x:105,y:69,special:3},{x:105,y:130,special:6},{x:237,y:61,special:5},{x:237,y:127,special:4},{x:423,y:232,special:2},{x:314,y:49,special:1},{x:386,y:49,special:6},{x:387,y:129,special:1},{x:446,y:98,special:0}];
_loc2_.iconFrameNum = 2;
_loc2_.enemyData = [{assetID:"puppy_mc",startPoint:"point20",type:"puppy",speed:50}];
_loc2_ = this.a_levels[2];
_loc2_.playerData = {assetID:"player_mc",x:111,y:235};
_loc2_.iconData = [{x:156,y:123,special:3},{x:156,y:82,special:6},{x:237,y:110,special:8},{x:237,y:170,special:7},{x:237,y:236,special:1},{x:401,y:232,special:0},{x:237,y:56,special:9},{x:320,y:320,special:2},{x:457,y:320,special:10},{x:543,y:320,special:11},{x:553,y:151,special:4},{x:552,y:54,special:5},{x:443,y:44,special:1}];
_loc2_.iconFrameNum = 3;
_loc2_.enemyData = [{assetID:"puppy_mc",startPoint:"point7",type:"puppy",speed:60}];
}
}